package com.htd.erp.purchase;

import javax.enterprise.context.ConversationScoped;
import javax.faces.event.ValueChangeEvent;
import javax.inject.Named;

import com.htd.erp.common.EntityHome;
import com.htd.erp.model.PurchaseItem;
import com.htd.erp.model.PurchaseTicket;

@Named
@ConversationScoped
public class PurchaseTicketHome extends EntityHome<PurchaseTicket> {

	private static final long serialVersionUID = -4001796784123087768L;

	public void addPurchaseItem() {
		entity.getPurchaseItems().add(new PurchaseItem());
	}
	
	public void onProductChange(ValueChangeEvent event) {
		logger.info("New value is {}", event.getNewValue());
	}
	
	@Override
	protected Class<PurchaseTicket> getEntityClass() {
		return PurchaseTicket.class;
	}

	@Override
	protected PurchaseTicket newEntityInstance() {
		return new PurchaseTicket();
	}
}
